


//
//  homecell.swift
//  mywei
//
//  Created by myd on 15/12/19.
//  Copyright © 2015年 myd1. All rights reserved.
//

import UIKit

class homecell: UITableViewCell {
    
    var imas = UIImageView()
    var textlmes = UILabel()
    var username = UILabel()
    
    
    
    
    var model : homeweimessage?
        {
        willSet{
       
        }
        didSet{
       imas.sd_setImageWithURL(NSURL(string: (model?.users?.profile_image_url)!))
        textlmes.text = model?.text
            username.text = model?.users?.screen_name
        }
    }
    
    
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
       super.init(style: UITableViewCellStyle.Subtitle, reuseIdentifier: reuseIdentifier)
        setview()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    func setview()
    {
   addSubview(imas)
        addSubview(textlmes)
        addSubview(username)
        username.font = UIFont.systemFontOfSize(15)
        textlmes.font = UIFont.systemFontOfSize(11)
        textlmes.numberOfLines = 0
        imas.translatesAutoresizingMaskIntoConstraints = false
        username.translatesAutoresizingMaskIntoConstraints = false
        textlmes . translatesAutoresizingMaskIntoConstraints = false
//        self.translatesAutoresizingMaskIntoConstraints = false
        self.contentView.translatesAutoresizingMaskIntoConstraints = false
    self.addConstraint(NSLayoutConstraint(item: imas, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self.contentView, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 10))
        self.addConstraint(NSLayoutConstraint(item: imas, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self.contentView, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 10))
        self.addConstraint(NSLayoutConstraint(item: imas, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 0, constant: 50))
        self.addConstraint(NSLayoutConstraint(item: imas, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 0, constant: 50))
        
        self.addConstraint(NSLayoutConstraint(item: username, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: imas, attribute: NSLayoutAttribute.Right, multiplier: 1, constant: 10))
        self.addConstraint(NSLayoutConstraint(item: username, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: imas, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0))
        
        self.addConstraint(NSLayoutConstraint(item: textlmes, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: username, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 10))
        self.addConstraint(NSLayoutConstraint(item: textlmes, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: username, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 0))
        self.addConstraint(NSLayoutConstraint(item: textlmes, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 250))
         self.addConstraint(NSLayoutConstraint(item: self.contentView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem:textlmes , attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 50))
   
        
        
    }
    
    
}
